<template>
    <div id="app">
        <router-view></router-view>
    </div>
</template>

<script>
    export default {
        name: 'app',
        computed: {
            userToken() {
                return this.$store.state.token;
            }
        },
        watch: {
            userToken(newVal) {
                this.init(newVal)
            }
        },
        mounted() {
            this.init(this.userToken);
        },
        methods: {
            init(token) {
                if (token !== '' && token !== undefined && token !== null) {
                    this.$router.push("/home")
                } else {
                    this.$router.push("/login")
                }
            }
        }
    }
</script>

<style>
    * {
        margin: 0px;
        padding: 0px;
    }

    #app {
        font-family: 'Avenir', Helvetica, Arial, sans-serif;
        -webkit-font-smoothing: antialiased;
        -moz-osx-font-smoothing: grayscale;
        /*text-align: center;*/
        /*color: #2c3e50;*/
        /*margin-top: 60px;*/
    }
</style>
